package com.b2.controller.wx;

import com.b2.pojo.dto.*;
import com.b2.pojo.vo.OperatedVideoVo;
import com.b2.pojo.vo.ParentVideoInformation;
import com.b2.pojo.vo.TeacherGetworksVo;
import com.b2.result.Result;
import com.b2.service.ParentVideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/wx/parentvideo")
@Slf4j
@Api(tags = "微信家长上传视频及其老师处理相关接口")
@CrossOrigin
public class ParentVideoController {

     @Autowired
     ParentVideoService parentVideoService;

     //第一次提交解读视频
     @PostMapping ("commitvideo")
     @ApiOperation(" '第一次提交解读视频'")
    public Result parentcommitvideo(@RequestBody ParentCommitVideoDto parentCommitVideoDto){
         parentVideoService.parentcommitvideo(parentCommitVideoDto);
         return Result.success();
    }


    //查询自己提交得解读视频及老师回复
    @GetMapping("getinformation")
     @ApiOperation("查询自己提交得解读视频及老师回复'")
    public Result<ParentVideoInformation> getinformation( Long videoid,Long classid){
       ParentVideoInformation parentVideoInformation= parentVideoService.getinformation(videoid,classid);
        return Result.success(parentVideoInformation);
    }


    //查看是否可以修改
    @GetMapping("getstatus")
     @ApiOperation("查看是否可以修改")
    public Result<Integer> getstatus( Long id){
        Integer status= parentVideoService.getstatus(id);
        return Result.success(status);
    }


    //修改解读视频
    //批改后不能修改
    @PostMapping ("updatevideo")
     @ApiOperation("修改解读视频")
    public Result parentupdatevideo(@RequestBody ParentUpdateVideoDto parentUpdateVideoDto){
        System.out.println(parentUpdateVideoDto);
        parentVideoService.parentupdatevideo(parentUpdateVideoDto);
        return Result.success();
    }


    //老师通过班级id和status得到自己得工作
    @PostMapping ("teahcergetworks")
     @ApiOperation("老师通过班级id和status得到自己得工作")
    public Result<List<TeacherGetworksVo>> teahcergetworks(@RequestBody TeacherGetWorksDto teacherGetWorksDto){

        List<TeacherGetworksVo> teacherGetworksVos=  parentVideoService.teahcergetworks(teacherGetWorksDto);
        return Result.success(teacherGetworksVos);
    }


    //发送图片url得到ai回答
    @PostMapping("getAiresponse")
     @ApiOperation("发送图片url得到ai回答")
    public String getAiresponse(@RequestBody AiDto aiDto){
        String AIresponse= parentVideoService.getAiresponse(aiDto);
        return AIresponse;
    }


    //老师提交回答
    @PostMapping("putTeacherResponse")
     @ApiOperation(" '老师提交回答'")
    public Result putTeacherResponse(@RequestBody TeacherResponseDto teacherResponseDto){
        parentVideoService.putTeacherResponse(teacherResponseDto);
        return Result.success();
    }



    //如果家长上传视频不对，老师修改状态为2（错误得状态）
    //驳回后必须要等被驳回人员修改后才能继续操作
    @PostMapping("TeacherUpdateStatus")
     @ApiOperation("如果家长上传视频不对，老师修改状态为2（错误得状态）驳回后必须要等被驳回人员修改后才能继续操作")
    public Result TeacherUpdateStatus(@RequestBody TeacherOverruleDto teacherOverruleDto){
         parentVideoService.TeacherUpdateStatus(teacherOverruleDto.getId(),teacherOverruleDto.getOverrule());
        return Result.success();
    }
    @PostMapping("GetOperatedVideo")
     @ApiOperation("查看自己得解读视频")
    public Result<List<OperatedVideoVo>> GetOperatedVideo(Integer status,String name){
        List<OperatedVideoVo> operatedVideoVos=parentVideoService.GetOperatedVideo(status,name);
        return Result.success(operatedVideoVos);
    }

}
